
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: load_api_config.py
@time: 2021/8/22 0022 17:45
@desc:
'''
from common.models import Config
from common.load_file import load_ini

class LoadApiConfig(object):
    __instance=None
    __inited=None

    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance=object.__new__(cls)
        return cls.__instance

    def __init__(self):
        if self.__inited is None:
            self.config=self._readConfig(r'D:\CodeBase\auto\AutomationAPI\conf\env.ini')
            self.__inited=True

    def _readConfig(self, configFile):
        doConfig = Config
        doConfig.url = load_ini('host', configFile)['stg_url']
        doConfig.init = load_ini('isInit', configFile)['init']
        return doConfig

if __name__ == '__main__':
    configFile = r"D:\CodeBase\auto\AutomationAPI\conf\env.ini"
    ku = load_ini('host', configFile)['stg_url']
    print(ku)